home *** CD-ROM | disk | FTP | other *** search
/ How Would You Survive? / How Would You Survive (1995)(Grolier)[Mac-PC].iso / mac / SHARED.DIR / 01989_Script_GameClass < prev    next >
Text File  |  1995-09-13  |  12KB  |  408 lines

  1. -- Question CastMembers chars 13 and 14 contain answer character and a-c and TOC association a-p
  2.  
  3. global gFullRandomList, gFullMasterRandomList
  4.  
  5. Property iChipList, iActiveQuestionList, iWorld, iLevel, iLiveGuys, iHalfLives
  6. property iQCastStart, iLifeCast, iHalfCast, iFirstChipSprite, iSuspended
  7. property iFirstLifeSprite, iLastQuestion, iQSprite, iAnswered, iScoreSprite, iLevSprite
  8. property iMaskLocList, iScore
  9.  
  10. global gAnsA, gAnsB, gAnsC, gGameBtn1, gGameBtn2, gGameBtn3, gGameBtn4, gBtn16, gBtn17
  11.  
  12.  
  13. on birth me, pLevel, pTheWorld
  14.   
  15.   if not(listp(gFullMasterRandomList)) then
  16.     set gFullMasterRandomList=[51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100]
  17.   end if
  18.   
  19.   if not(listp(gFullRandomList)) then
  20.     set gFullRandomList=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50]
  21.   end if
  22.   
  23.   
  24.   mPrepGame me, pTheWorld
  25.   set iLevel=pLevel
  26.   set iSuspended=0
  27.   set vStartScores=[10,5,3,3]
  28.   set iMaskLocList=["A":190,"B":230,"C":270]
  29.   set iLiveGuys=getat(vStartScores,iLevel)
  30.   set iHalfLives=0
  31.   set iScore=0
  32.   set iFirstLifeSprite=2
  33.   set iFirstChipSprite=iFirstLifeSprite+10
  34.   set iLastQuestion=0
  35.   set iAnswered=0
  36.   set iQSprite=22
  37.   set iScoreSprite =23
  38.   set iLevSprite=28
  39.   mGetQList(me)
  40.   msetPuppets(me)
  41.   mSetLevel(me)
  42.   return me
  43. end birth
  44.  
  45. on mPrepGame me, pTheWorld
  46.   set iWorld=pTheWorld
  47.   set iLifeCast=the number of cast "Large Boy Icon"
  48.   set iHalfCast=the number of cast "Small Boy Icon"
  49.   set iQCastStart=the number of cast "QuestionStart"
  50.   if listp(iChipList) then
  51.     repeat with x=1 to 10
  52.       set vChip=getat(iChiplist, x)
  53.       set vQuestionName=char 14 to 16 of the name of cast¼
  54.           (iQCastStart+getat(iActiveQuestionList,x))
  55.       mRedefineChipCast(vChip, vQuestionName)
  56.     end repeat
  57.   end if
  58.   
  59.   
  60. end mPrepGame
  61.  
  62.  
  63.  
  64. on mSetPuppets me
  65.   repeat with x=1 to 10
  66.     set vSprite=(x-1)+iFirstLifeSprite
  67.     if not(the puppet of sprite vSprite) then puppetsprite vSprite, true
  68.   end repeat
  69. end mSetPuppets
  70.  
  71. on mSetLevel me
  72.   puppetsprite iLevsprite, true
  73.   set vLevCast=the number of cast(char 1 of the moviename&".Level "&iLevel)
  74.   set the castnum of sprite iLevSprite=vLevCast
  75.   updatestage
  76. end mSetLevel
  77.  
  78. on mRedrawChips me
  79.   repeat with x=1 to 10
  80.     set vChipToUpdate=getat(iChipList,x)
  81.     mUpdateChip(vChipToUpdate,0)
  82.   end repeat
  83. end mRedrawChips
  84.  
  85. on mResumeGame me
  86.   mSetPuppets me
  87.   mSetLevel me
  88.   mRedrawChips me
  89.   mUpdateScore me
  90.   mShowBasicGameControls me
  91.   if iSuspended then
  92.     mShowQuestion me, iSuspended
  93.     puppetsprite 43, true
  94.     set vLastChip=getat(iChipList,iSuspended)
  95.     set vWrongAnswer=mGetWrongAnswer(vLastChip)
  96.     set the locv of sprite 43=getaprop(iMaskLocList, vWrongAnswer)
  97.   end if
  98. end mResumeGame
  99.  
  100. on mShowBasicGameControls me
  101.   showcontrol(gGameBtn1)
  102.   showcontrol(gGameBtn2)  
  103.   showcontrol(gGameBtn3)
  104.   showcontrol(gBtn16)
  105.   showcontrol(gBtn17)
  106. end mShowBasicGameControls
  107.  
  108. -- GENERATE THE QUESTIONS TO BE USED IN THIS GAME
  109. on mGetQList me
  110.   
  111.   set iActiveQuestionList=[]
  112.   set iChipList=[]
  113.   set the randomseed=the timer
  114.   repeat with x=1 to 10
  115.     
  116.     
  117.     if iLevel>3 then
  118.       set vListLen=count(gFullMasterRandomList)
  119.       if (vListLen=0) or (vListlen<=count(iActiveQuestionList)) then
  120.         set gFullMasterRandomList=[51,52,53,54,55,56,57,58,59,60,61,62,63,64,65,66,67,68,69,70,71,72,73,74,75,76,77,78,79,80,81,82,83,84,85,86,87,88,89,90,91,92,93,94,95,96,97,98,99,100]
  121.       end if
  122.       set vValid=false
  123.       repeat while vValid=false
  124.         set z=random(count(gFullMasterRandomList))
  125.         set y=getat(gFullMasterRandomList,z)
  126.         set vValid=not(mFindNumInList(me, y, iActiveQuestionList))
  127.       end repeat
  128.       
  129.     else
  130.       set vListLen=count(gFullRandomList)
  131.       if (vListLen=0) or (vListlen<=count(iActiveQuestionList)) then
  132.         set gFullRandomList=[1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50]
  133.       end if
  134.       set vValid=false
  135.       repeat while vValid=false
  136.         set z=random(count(gFullRandomLIst))
  137.         set y=getat(gFullRandomList,z)
  138.         set vValid=not(mFindNumInList(me, y, iActiveQuestionList))
  139.       end repeat
  140.     end if
  141.     
  142.     add(iActiveQuestionList, y)
  143.     
  144.     set vSprite=(x-1)+iFirstChipSprite
  145.     set vQCast=iQCastStart+y
  146.     set vTocLink=char 14 of the name of cast vQCast
  147.     
  148.     if (iLevel=4) then put char 15 to 16 of (the name of cast vQCast) after vTocLink
  149.     set vNewChip=birth(script"chipClass", vSprite, x, vTOCLink)
  150.     add(iChipList, vNewChip)
  151.     mUpdateChip(vNewChip,0)
  152.   end repeat
  153. end mGetQList
  154.  
  155.  
  156. on mFindNumInList me, pNum, pList
  157.   set vListLen=count(pList)
  158.   set vInList=false
  159.   if vListLen>0 then
  160.     set vNumToCheck=1
  161.     repeat while (vNumToCheck<=vListLen) and not vInList
  162.       set vInList=(pNum=getat(pList, vNumTocheck))
  163.       set vNumToCheck=vNumToCheck+1
  164.     end repeat
  165.   end if
  166.   return vInList*(vNumToCheck-1)
  167. end mFindNumInList
  168.  
  169. -- CHECK IF THE CLICKED ANSWER IS CORRECT
  170. on mRightAnswer me, pAnswer, pQuestion
  171.   -- passed the answer letter submitted by the user and the question# (1-10) that has been answered
  172.   set vQuestionCast=getat(iActiveQuestionList, pQuestion)+iQCastStart
  173.   set vRightAnswer=char 13 of the name of cast vQuestionCast
  174.   put "Right Answer is:"&vRightAnswer
  175.   put "answer submitted is:"&pAnswer
  176.   return vRightAnswer=pAnswer
  177. end mRightAnswer
  178.  
  179. on mUserAnswers me, pUserAnswer
  180.   --  puppetsound 0
  181.   --  set vSound=cast "Guess"
  182.   --  puppetsound vSound
  183.   --  updatestage  
  184.   
  185.   set vActiveChip=getat(iChipList, iLastQuestion)
  186.   sound close 2
  187.   if mRightAnswer(me, pUserAnswer, iLastQuestion) then
  188.     set vSound=cast "Right"
  189.     puppetsound vSound
  190.     set iAnswered=iAnswered+1
  191.     if (mGetChipState(vActiveChip)=3) then 
  192.       set iHalfLives=iHalfLives-1
  193.     end if
  194.     set iScore=iScore+1
  195.     mSetChipState(vActiveChip,1)
  196.   else -- wrong answer
  197.     set vSound=cast "Wrong"
  198.     puppetsound vSound
  199.     put "Here's mgetchipstate:"&(mgetchipstate(vActiveChip))
  200.     mSetWrongAnswer(vActiveChip, pUserAnswer)
  201.     
  202.     if iLevel=4 or (mGetChipState(vActiveChip)=3) then
  203.       if iLevel<>4 then 
  204.         set iHalfLives=iHalfLives-1
  205.       end if
  206.       set iAnswered=iAnswered+1
  207.       set iLiveGuys=iLiveGuys-1
  208.     else -- the chip is going to go to TOC state
  209.       set iHalfLives=iHalfLives+1
  210.     end if
  211.   end if
  212.   -- if last question in master game then last chip can not go to TOC
  213.   if iAnswered=10 and iLevel=4 then
  214.     mFryLastChip(me)
  215.   end if
  216.   
  217.   --  repeat while soundbusy(1)
  218.   --  end repeat
  219.   
  220.   mUpdateScore me
  221.   repeat with x=1 to 500
  222.     updatestage
  223.   end repeat
  224.   mClearQuestion me, iLastQuestion
  225.   set vEndMovie=(char 1 of the moviename&"GMEND.DIR")
  226.   put vEndMovie
  227.   if iLiveGuys=0 then
  228.     TurnOffPuppets 1--APN 7/19
  229.     go frame "GameEnd0" of movie vEndMovie
  230.   else
  231.     if iAnswered=10 then
  232.       TurnOffPuppets 1--APN 7/19
  233.       if iScore>8 then 
  234.         go frame ("GameEnd3") of movie vEndMovie
  235.       else
  236.         if iScore>4 then 
  237.           go frame "GameEnd2" of movie vEndMovie
  238.         else -- score is less than 5
  239.           go frame "GameEnd1" of movie vEndMovie
  240.         end if
  241.       end if
  242.     end if
  243.   end if
  244. end mUserAnswers
  245.  
  246. on mFryLastChip me
  247.   set vChipToFry = getat(iChiplist, iLastQuestion)
  248.   msetchipstate(vChipToFry,1)
  249. end mFryLastChip
  250.  
  251.  
  252. on mUpdateScore me
  253.   set vScoreString=iScore
  254.   if iScore<10 then put "0" before vScoreString
  255.   if not(the puppet of sprite iscoresprite) then puppetsprite iscoresprite,true
  256.   set the castnum of sprite iScoreSprite=the number of cast (iWorld&".Score "&vScoreString)
  257.   updatestage
  258.   mDrawLives me
  259. end mUpdatescore
  260.  
  261. on mDrawLives me
  262.   set vFullGuys=iLiveGuys-iHalfLives
  263.   
  264.   if vFullGuys<0 then set vFullGuys=0
  265.   
  266.   if iLiveGuys<10 then
  267.     repeat with x=iLiveGuys+1 to 10
  268.       set vSprite=((x-1)+iFirstLifeSprite)
  269.       set the locv of sprite vSprite=880
  270.       updatestage
  271.     end repeat
  272.   end if
  273.   
  274.   repeat with x= 1 to vFullGuys
  275.     set vSprite=((x-1)+iFirstLifeSprite)
  276.     set the loch of sprite vSprite=503-((x-1)*39)
  277.     set the locv of sprite vSprite=442
  278.     set the castnum of sprite vSprite=iLifeCast
  279.     updatestage
  280.   end repeat
  281.   if iHalfLives>0 then
  282.     set vBeginningLoc=503-((vFullGuys)*39)
  283.     repeat with x=1 to iHalfLives
  284.       set vSprite=((x-1)+iFirstLifeSprite)+vFullGuys
  285.       set the loch of sprite vSprite=vBeginningLoc-((x-1)*39)
  286.       set the locv of sprite vSprite=442
  287.       set the castnum of sprite vSprite=iHalfCast
  288.       updatestage
  289.     end repeat
  290.   end if
  291. end mDrawLives
  292.  
  293. on mPrepClearBoard me
  294.   mClearLives me
  295.   mRestartChips me
  296. end mPrepClearBoard
  297.  
  298. on mClearLives me
  299.   repeat with x=0 to 9
  300.     set vSpriteToFix=x+iFirstLifeSprite
  301.     if not(the puppet of sprite vSpriteToFix) then puppetsprite x, true
  302.     set the locv of sprite vSpriteToFix=880
  303.     updatestage
  304.   end repeat
  305. end mClearLives
  306.  
  307. on mRestartChips me
  308.   repeat with x=1 to 10
  309.     set vChipToFlip=getat(iChipList, x)
  310.     mResetChip(vChipToFlip)
  311.   end repeat
  312. end mRestartChips
  313.  
  314. on mClearChips me
  315.   repeat with x=1 to 10
  316.     set vChipToFlip=getat(iChipList, x)
  317.     mKillChip(vChipToFlip)
  318.   end repeat
  319. end mClearChips
  320.  
  321. on mGetLevel me
  322.   return iLevel
  323. end mGetLevel
  324.  
  325. on mGetChipList me
  326.   return iChipList
  327. end mGetChiplist
  328.  
  329. on mGetWorld me
  330.   return iworld
  331. end mGetWorld
  332.  
  333. on mShowQuestion me, pQNum
  334.   set x=cast "Whoosh"
  335.   puppetsound x
  336.   go frame "Questions"
  337.   puppetsprite iQSprite, true
  338.   set vCurrentQuestion=getat(iActiveQuestionList, pQNum)
  339.   set the castnum of sprite iQSprite=iQCastStart+vCurrentQuestion
  340.   updatestage
  341.   if iLastQuestion>0 then -- if in master game, opening a question kills last TOC chip
  342.     set vLastChip=getat(iChipList, iLastQuestion)
  343.     if iLevel=4 and mGetChipState(vLastChip)=3 then
  344.       mSetChipState(vLastChip, 1)
  345.       mUpdateChip(vLastChip,0)
  346.     end if
  347.   end if
  348.   set iLastQuestion=pQNum
  349.   showcontrol(gAnsA)
  350.   showcontrol(gAnsB)
  351.   showcontrol(gAnsC)
  352.   if iLevel>3 then
  353.     mKillQuestion me, gFullMasterRandomList, vCurrentQuestion
  354.   else
  355.     mKillQuestion me, gFullRandomList,vCurrentQuestion
  356.   end if
  357.   put "Question:"&vCurrentQuestion
  358.   --showcontrol(gGameBtn4)
  359. end mShowQuestion
  360.  
  361. on mKillQuestion me, pListToCheck, pItemToKill
  362.   set vLoc= mFindNumInList (me, pItemToKill, pListToCheck)
  363.   if vLoc then deleteat(pListToCheck, vLoc)
  364. end mKillQuestion
  365.  
  366. on mClearQuestion me, pQuestion
  367.   puppetsprite iQSprite, false
  368.   hidecontrol(gAnsA)
  369.   hideControl(gAnsB)
  370.   hideControl(gAnsC)
  371.   --hidecontrol(gGameBtn4)
  372.   if iSuspended then
  373.     set the locv of sprite 43=900
  374.     puppetsprite 43, false
  375.     mClearSuspended(me)
  376.   end if
  377.   go frame "Chips"
  378.   mUpdateChip(getat(iChipList, pQuestion),1)
  379. end mClearQuestion
  380.  
  381. on mSetSuspended me, pQNum
  382.   set iSuspended=pQNum
  383. end mSetSuspended
  384.  
  385. on mClearSuspended me
  386.   set iSuspended=0
  387. end mClearSuspended
  388.  
  389. on mFullLivesOpen me
  390.   return iLiveGuys>iHalfLives
  391. end mFullLivesOpen
  392.  
  393. on mFlushOtherTocs me
  394.   repeat with x=1 to 10
  395.     set vChiptocheck=getat(iChiplist,x)
  396.     if mgetchipstate(vChipToCheck)=3 then
  397.       msetchipstate(vChipToCheck,1)
  398.     end if
  399.   end repeat
  400. end mFlushOtherTocs
  401.  
  402. on mFlushChips me
  403.   repeat with x=1 to 10
  404.     set vChip=getat(ichiplist,x)
  405.     mUnPuppetChip(vChip)
  406.     updatestage
  407.   end repeat
  408. end mFlushChips